From: Brion Vibber Date: Sat, 20 Nov 2004 04:23:52 +0000 (+0000) Subject: Preparing to remove the bundled PHPTAL and let the PHPTAL skins (if enabled) work... X-Git-Tag: 1.5.0alpha1~1301 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=762cefe527416b1862eb22698d701247b6023971;p=lhc%2Fweb%2Fwiklou.git Preparing to remove the bundled PHPTAL and let the PHPTAL skins (if enabled) work with an externally-installed PEAR+PHPTAL. $wgUsePHPTal setting no longer exists; if a PHPTAL-based skin is used it will attempt to load PEAR+PHPTAL and gracefully disable itself if it can't. Todo: get the list of skins in preferences to reflect this kind of disabling, so unselectable skins don't need to be moved into disabled subdir to be hidden. --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 11c9cea97e..1d5c0fb7fe 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -608,17 +608,6 @@ $wgSVGConverters = array( $wgSVGConverter = 'ImageMagick'; # Pick one of the above $wgSVGConverterPath = ''; # If not in the executable PATH, specify -# PHPTAL is a library for page templates. This is optional; -# MediaWiki's internal skins no longer use it but you might -# create your own custom skin using it. -# -# Use PHPTAL 0.7.0 for PHP 4.x or PHPTAL 1.0.0 for PHP 5.0. -# http://phptal.sourceforge.net/ -# -# Leave it off to avoid trying to load the template library -# if you're not going to be using any such skins. -$wgUsePHPTal = false; - if( !isset( $wgCommandLineMode ) ) { $wgCommandLineMode = false; } diff --git a/includes/SkinPHPTal.php b/includes/SkinPHPTal.php index 082e52fc00..a0532035bf 100644 --- a/includes/SkinPHPTal.php +++ b/includes/SkinPHPTal.php @@ -19,13 +19,14 @@ * Based on Brion's smarty skin * Copyright (C) Gabriel Wicke -- http://www.aulinx.de/ * - * Todo: Needs some serious refactoring into functions that correspond - * to the computations individual esi snippets need. Most importantly no body - * parsing for most of those of course. - * - * Set this in LocalSettings to enable phptal: - * set_include_path(get_include_path() . ":" . $IP.'/PHPTAL-NP-0.7.0/libs'); - * $wgUsePHPTal = true; + * The guts of this have moved to SkinTemplate.php + * + * Make sure the appropriate version of PHPTAL is installed (0.7.0 for PHP4, + * or 1.0.0 for PHP5) and available in the include_path. The system PEAR + * directory is good. + * + * If PEAR or PHPTAL can't be loaded, it will try to gracefully fall back. + * Turn on MediaWiki's debug log to see it complain. * * @package MediaWiki * @subpackage Skins @@ -42,15 +43,28 @@ require_once 'SkinTemplate.php'; if( version_compare( phpversion(), "5.0", "lt" ) ) { define( 'OLD_PHPTAL', true ); - global $IP; - require_once $IP.'/PHPTAL-NP-0.7.0/libs/PHPTAL.php'; + # PEAR and PHPTAL 0.7.x must be installed and in include_path } else { define( 'NEW_PHPTAL', true ); - # For now, PHPTAL 1.0.x must be installed via PEAR in system dir. - require_once 'PEAR.php'; - require_once 'PHPTAL.php'; + # PEAR and PHPTAL 1.0.x must be installed and in include_path +} + +@include_once 'PEAR.php'; +if( !class_exists( 'PEAR' ) ) { + wfDebug( 'PHPTAL-based skin couldn\'t include PEAR.php' ); +} else { + +// PHPTAL may be in the libs dir direct, or under HTML/Template. +// Try them both to be safe. +@include_once 'HTML/Template/PHPTAL.php'; +if( !class_exists( 'PHPTAL' ) ) { + @include_once 'PHPTAL.php'; } +if( !class_exists( 'PHPTAL' ) ) { + wfDebug( 'PHPTAL-based skin couldn\'t include PHPTAL.php' ); +} else { + /** * * @package MediaWiki @@ -130,5 +144,7 @@ class PHPTAL_version_bridge { } } +} // end of if( class_exists( 'PHPTAL' ) ) +} // end of if( class_exists( 'PEAR' ) ) } // end of if( defined( 'MEDIAWIKI' ) ) ?> diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php index 780ed17160..8706e29705 100644 --- a/includes/SkinTemplate.php +++ b/includes/SkinTemplate.php @@ -24,10 +24,9 @@ * to the computations individual esi snippets need. Most importantly no body * parsing for most of those of course. * - * PHPTAL support has been moved to a subclass in SkinPHPTal.php - * Set this in LocalSettings to enable phptal: - * set_include_path(get_include_path() . ":" . $IP.'/PHPTAL-NP-0.7.0/libs'); - * $wgUsePHPTal = true; + * PHPTAL support has been moved to a subclass in SkinPHPTal.php, + * and is optional. You'll need to install PHPTAL manually to use + * skins that depend on it. * * @package MediaWiki * @subpackage Skins diff --git a/maintenance/commandLine.inc b/maintenance/commandLine.inc index 463366ef3f..ce22a41ac0 100644 --- a/maintenance/commandLine.inc +++ b/maintenance/commandLine.inc @@ -140,7 +140,6 @@ $wgDBuser = $wgDBadminuser; $wgDBpassword = $wgDBadminpassword; -$wgUsePHPTal = false; require_once( "Setup.php" ); require_once( "install-utils.inc" ); $wgTitle = Title::newFromText( "Command line script" ); diff --git a/maintenance/liveCmdLine.inc b/maintenance/liveCmdLine.inc index a3a28cadeb..529bf6f2cc 100644 --- a/maintenance/liveCmdLine.inc +++ b/maintenance/liveCmdLine.inc @@ -48,8 +48,6 @@ ini_set( "include_path", "/home/wikipedia/common/php-new:/home/wikipedia/common/ require_once( "/home/wikipedia/common/php-new/CommonSettings.php" ); -$wgUsePHPTal = false; - define("MEDIAWIKI",true); require_once( "Setup.php" ); require_once( "../install-utils.inc" ); diff --git a/skins/SkinPHPTal.sample b/skins/SkinPHPTal.sample index a85702bc81..683c208070 100644 --- a/skins/SkinPHPTal.sample +++ b/skins/SkinPHPTal.sample @@ -1,27 +1,28 @@ skinname = 'name of your skin all lower case'; - $this->template = 'phptal template used do not put the .pt'; +# Test if PHPTal is enabled. If not MediaWiki will load the 'standard' skin +# which doesnt use PHPTal +if( class_exists( 'SkinPHPTal' ) ) { + + # Your class extension is defined there. + # + # The class name MUST begin with 'Skin' and the rest is the name of the file + # excluding '.php' + # This file is named SkinPHPTal.sample (but it should end with php). So the + # class name will be 'Skin' . 'SkinPHPTal' + + class SkinSkinPHPTal extends SkinPHPTal { + function initPage( &$out ) { + SkinPHPTal::initPage( $out ); + $this->skinname = 'name of your skin all lower case'; + $this->template = 'phptal template used do not put the .pt'; + } + + # Override method below + # + } -# Override method below -# - -} - } ?> diff --git a/skins/disabled/Amethyst.php b/skins/disabled/Amethyst.php index d5e6397c0e..3bfaa18f99 100644 --- a/skins/disabled/Amethyst.php +++ b/skins/disabled/Amethyst.php @@ -13,8 +13,8 @@ */ /** */ -if ($wgUsePHPTal) { require_once('includes/SkinPHPTal.php'); +if( class_exists( 'SkinPHPTal' ) ) { /** * See skin.doc diff --git a/skins/disabled/Chick.php b/skins/disabled/Chick.php index f3e06f3775..ee28850a10 100644 --- a/skins/disabled/Chick.php +++ b/skins/disabled/Chick.php @@ -8,8 +8,8 @@ */ /** */ -if ($wgUsePHPTal) { require_once('includes/SkinPHPTal.php'); +if( class_exists( 'SkinPHPTal' ) ) { /** * See skin.doc diff --git a/skins/disabled/MonoBookTal.php b/skins/disabled/MonoBookTal.php index d565122a84..bc0f1215c7 100644 --- a/skins/disabled/MonoBookTal.php +++ b/skins/disabled/MonoBookTal.php @@ -15,30 +15,27 @@ */ /** */ -if( defined( 'MEDIAWIKI' ) ) { - -global $wgUsePHPTal; -if ($wgUsePHPTal) { require_once('includes/SkinPHPTal.php'); -/** - * Inherit everything from SkinPHPTal - * This is a dummy skin as MonoBook is the default PHPTal skin. - * @todo document - * @package MediaWiki - * @subpackage Skins - */ -class SkinMonoBookTal extends SkinPHPTal { - /** Using monobook. */ - function initPage( &$out ) { - SkinPHPTal::initPage( $out ); - $this->skinname = 'monobooktal'; - $this->stylename = 'monobook'; - $this->template = 'MonoBook'; +# Test if PHPTal is enabled. If not MediaWiki will load the 'standard' skin +# which doesnt use PHPTal +if( class_exists( 'SkinPHPTal' ) ) { + /** + * Inherit everything from SkinPHPTal + * This is a dummy skin as MonoBook is the default PHPTal skin. + * @todo document + * @package MediaWiki + * @subpackage Skins + */ + class SkinMonoBookTal extends SkinPHPTal { + /** Using monobook. */ + function initPage( &$out ) { + SkinPHPTal::initPage( $out ); + $this->skinname = 'monobooktal'; + $this->stylename = 'monobook'; + $this->template = 'MonoBook'; + } } -} - -} } ?> diff --git a/skins/disabled/WikimediaWiki.php b/skins/disabled/WikimediaWiki.php index 3e125b34c2..26ce0ccb37 100644 --- a/skins/disabled/WikimediaWiki.php +++ b/skins/disabled/WikimediaWiki.php @@ -9,8 +9,8 @@ /** */ -if($wgUsePHPTal) { require_once('includes/SkinPHPTal.php'); +if( class_exists( 'SkinPHPTal' ) ) { $wgExtraSkins['wikimediawiki'] = 'Wikimediawiki';